package zzcltw.com.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import zzcltw.com.mapper.RecruitMapper;
import zzcltw.com.object.Recruit;
import zzcltw.com.service.IRecruitService;
import zzcltw.com.service.common.impl.BaseServiceImpl;

@Service("recruitService")
public class RecruitServiceImpl extends BaseServiceImpl implements IRecruitService{
	@Autowired
	private RecruitMapper recruitMapper;
	/**
	 * 招聘信息列表查询
	 */
	@Override
	public Map<String, Object> queryRecruitList(Map<String, String> map) {
		List<Map<String,String>> list = recruitMapper.queryRecruitList(map);
		int count = recruitMapper.queryRecruitListCount(map);
		Map<String,Object> bean = new HashMap<>();
		bean.put("total", Integer.toString(count));
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", list);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  招聘信息详情
	 * @Description:  queryRecruitDtlById
	 * @param: @param recruit
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年8月23日
	 */
	public Map<String,Object> queryRecruitDtlById(Map<String,String> map){
		Map<String,String> bean = recruitMapper.queryRecruitDtlById(map);
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", null);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	@Override
	public Map<String,Object> saveRecruitInfo(Recruit recruit) throws Exception {
		String recruitId = getSequence("t_pt_recruit");		
		recruit.setRecruitId(recruitId);
		recruit.setValidStsCd("1");
		int flag = recruitMapper.saveRecruitInfo(recruit);
		Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}

	@Override
	public Map<String,Object> updateRecruitInfo(Recruit recruit) throws Exception {
		int flag = recruitMapper.updateRecruitInfo(recruit);
		Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}

	@Override
	public Map<String,Object> delRecruitInfo(Map<String,String> map) throws Exception {
		int flag = recruitMapper.delRecruitInfo(map);
		Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
    	Map<String,Object> map1 = new HashMap<>();
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", "");		
    	return map1;
	}

}
